#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<char> v;
    string s;
    cin >> s;
    int c = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '(' or s[i] == '<' or s[i] == '{' or s[i] == '[')
        {
            v.push_back(s[i]);
        }
        else if (v.size() == 0 and (s[0] == ')' or s[0] == ']' or s[0] == '>' or s[0] == '}'))
        {
            c += 1;
        }
        if ((s[i] == ')' or s[i] == '>' or s[i] == '}' or s[i] == ']') and v.size() != 0)
        {
            if (v.back() == '(' and s[i] == ')')
            {
                v.pop_back();
            }
            if (v.back() == '[' and s[i] == ']')
            {
                v.pop_back();
            }
            if (v.back() == '{' and s[i] == '}')
            {
                v.pop_back();
            }
            if (v.back() == '<' and s[i] == '>')
            {
                v.pop_back();
            }
        else
        {
            c += 1;
        }
        }
        }
if (c > 1)
{
    cout << "False";
}
else if (v.size() == 0)
{
    cout << "True";
}
else
{
    cout << "False";
}
    return 0;
}
